#include "sys.h"
															//	8	9 	 11 -
unsigned char code  smg[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff,0xbf};
u8 NixieBuff[8] ={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
u8 smg1,smg2,smg3,smg4,smg5,smg6,smg7,smg8;

void Nixie_Scan()
{
	static u8 index;
	
	P0 = 0xff;
	hc138(7);
	hc138(0);
	
	P0 = 0x01 << index;
	hc138(6);
	hc138(0);
	
	P0 = NixieBuff[index];
	hc138(7);
	hc138(0);
	index++;
	index &= 0x07;
}


void Nixie_Show()
{
	NixieBuff[0] = smg[smg1];
	NixieBuff[1] = smg[smg2];
	NixieBuff[2] = smg[smg3];
	NixieBuff[3] = smg[smg4];
	NixieBuff[4] = smg[smg5];
	NixieBuff[5] = smg[smg6];
	NixieBuff[6] = smg[smg7];
	NixieBuff[7] = smg[smg8];
}

void showMode0()
{
	smg1 = smg2 = smg3 = smg4 = smg5 = smg6 = smg7 = smg8 = 10;
	if(S4 == 0)
	{
		smg7 = 11;
		smg8 = PWM;
		while(!S4);
	}
}
void showMode1()
{
	if(flag800ms)
	{	
		smg1 = 11;
		smg2 = workMode;
		smg3 = 11;
		smg4 = 10;
		
	}else{
		smg1 = smg2 = smg3 = smg4  = 10;
	}
	if(timeMode > 9)
	{
			smg5 = timeMode /10;
	}else{
			smg5 = 10;
	}
		smg6 = timeMode%10;
		smg7 = 0;
		smg8 = 0;
}
void showMode2()
{
	smg1 = 11;
	smg2 = workMode;
	smg3 = 11;
	smg4 = 10;
	if(flag800ms)
	{	if(timeMode > 9)
		{
			smg5 = timeMode /10;
		}else{
			smg5 = 10;
		}
		smg6 = timeMode%10;
		smg7 = 0;
		smg8 = 0;
	}else{
		smg5 = smg6 = smg7 = smg8 = 10;
	}
}


void show_mode()
{
	switch(showMode)
	{
		case 0:showMode0();break;
		case 1:showMode1();break;
		case 2:showMode2();break;
		default:break;
	}
}